﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Data.Common;

/// <summary>
/// Summary description for AbstractDAOFactory
/// </summary>
public abstract class AbstractDAOFactory {
	public enum Type {
		MySQL
	}

	protected static Dictionary<Type, AbstractDAOFactory> factoryInstances;

	public abstract DbConnection getConnection();

	public static AbstractDAOFactory getInstance(Type type) {
		if (AbstractDAOFactory.factoryInstances == null) {
			AbstractDAOFactory.factoryInstances = new Dictionary<Type, AbstractDAOFactory>();
		}

		AbstractDAOFactory result = null;
		if (AbstractDAOFactory.factoryInstances.ContainsKey(type)) {
			result = AbstractDAOFactory.factoryInstances[type];
		} else { // If need be, create new factory
			switch (type) {
				case Type.MySQL:
					result = new MySQLDAOFactory();
					break;
			}

			AbstractDAOFactory.factoryInstances[type] = result;
		}

		return result;
	}

	public abstract IProfileDAO createProfileDAO();

	public abstract IScheduleDAO createScheduleDAO();

	public abstract IDestinationDAO createDestinationDAO();
}
